package com.burges.net.dataStream.codeRuler.dataInputStream.datasources;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 创建人    BurgessLee
 * 创建时间   2020/1/26
 * 描述     集合类数据源
 */
public class CollectionDataSourceDemoJava {

    public static void main(String[] args) {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        //通过fromCollection从数组转创建DataSource数据集
        String[] elements = new String[]{"hello","flink"};
        DataStream<String> dataStream = env.fromCollection(Arrays.asList(elements));
        System.out.println(dataStream);

        // 将java.util.List转换成DataStream数据集
        List<String> arrayList = new ArrayList<String>();
        arrayList.add("hello flink");
        DataStream<String> dataList = env.fromCollection(arrayList);
        System.out.println(dataList);
    }

}
